import {http} from '@/core'

// 首页
export const GetClueList = (limit, offset, orderBy, direction, param) => {
  return http.post(`business/myList?limit=${limit}&offset=${offset}&orderby=${orderBy}&direction=${direction}`, param)
}
export const GetBusinessList = (limit, offset, orderBy, direction, param) => {
  return http.post(`opportunity/myList?limit=${limit}&offset=${offset}&orderby=${orderBy}&direction=${direction}`, param)
}
// 产品
export const GetAllProducts = () => {
  return http.get('productType/getList?status=1')
}

// 跟进记录
export const GetLogList = (limit, offset, orderBy, direction, param) => {
  return http.post(`follow/follows?limit=${limit}&offset=${offset}&orderby=${orderBy}&direction=${direction}`, param)
}
// 获取一级行业
export const GetOnelevelIndustries = () => {
  return http.post('cmsIndustry/oneLevelIndustries', {
    'headers': {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
// 获取二级行业
export const GetTwoLevelIndustries = (param) => {
  return http.post('cmsIndustry/industries', param)
}
export const GetDepartment = () => {
  return http.get('organization/allOrganizations')
}
// 获取数据字典
export const GetDictionary = () => {
  return http.get('crmDictionary/crmDictionaries')
}
// 地区
export const GetAreas = () => {
  return http.get('areas/0/subareas')
}
export const GetSubareas = (areaId) => {
  return http.get(`areas/${areaId}/subareas`)
}
// 来源
export const GetSourceList = (param) => {
  return http.post('sourcetype/getSubList', param)
}

// 获取线索详情
export const GetClueDetail = (pid) => {
  return http.get(`business/get?pid=${pid}`)
}
// 获取商机详情
export const GetBusinessDetail = (pid) => {
  return http.get(`opportunity/get?pid=${pid}`)
}

export const GetContracts = (param) => {
  return http.post('contact/typeList', param)
}
export const GetLogWays = () => {
  return http.get('followWay/getList')
}
export const AddLog = (param) => {
  return http.put('business/log', param)
}
export const GetBusinessDistinct = (param) => {
  return http.post('business/getFirst5', param)
}
// 回池线索
export const ExitBusiness = (param) => {
  return http.put('business/backToCluePool', param)
}
// 转出: 线索、商机
export const TransferBusiness = (param) => {
  return http.put('business/outSelf', param)
}
// 收回线索
export const RetrieveBusiness = (param) => {
  return http.put('business/takeback', param)
}
export const GetProductList = () => {
  return http.get('productType/getAllTypeList')
}
export const GetSubProductList = (pid) => {
  return http.get(`product/getList?parentId=${pid}`)
}
export const GetPeriodList = () => {
  return http.get('salePeriod/getList')
}

// 商机类型
export const GetDict = (code) => {
  return http.get(`crmDictionary/crmDictionaries/typeCode/${code}`)
}
// 产品包
export const GetProductPackage = () => {
  return http.post('package/getList')
}
// 产品详情
export const GetProductDetail = (pid) => {
  return http.get(`product/get?pid=${pid}`)
}
